# -*- coding: utf-8 -*-

from odoo import models, fields, api


class StockMove(models.Model):
    _inherit = 'stock.move'
    dest_name=fields.Char(related='location_id.dest_name',store=True)
    @api.model
    def create(self, vals_list):
        if 'sale_line_id' in  vals_list and vals_list['sale_line_id']:
            line_id=self.env['sale.order.line'].sudo().browse(vals_list['sale_line_id'])
            dest_location_id=line_id.boat_location_id.id
            if dest_location_id:
                vals_list['location_id']=dest_location_id
        # if 'purchase_line_id' in  vals_list and vals_list['purchase_line_id']:
        #     line_id=self.env['purchase.order.line'].sudo().browse(vals_list['purchase_line_id'])
        #     dest_location_id=line_id.boat_location_id.id
        #     if dest_location_id:
        #         vals_list['location_dest_id']=dest_location_id


        return super(StockMove, self).create(vals_list)

class Stockquant(models.Model):
    _inherit = 'stock.quant'
    dest_name=fields.Char(related='location_id.dest_name',store=True)

